### Alizade, Dancygier, Ditlmann 
### "National Penalties Reversed"
### Replication Code 
### Table 5 (Column 1)
### For questions, contact jalizade@princeton.edu

# empty environment
rm(list = ls())

#setwd("")
setwd("C:/Users/Jey/Dropbox/WZB/NaturalizationExperiment/Submission/JOP/replication_JOP/data")

# load necessary packages
library(readstata13)
library(lmtest)
library(sandwich)

# load data set
dat <- read.dta13("data_experimental.dta")

# relevel treatment variable
dat$e2_treat <- factor(dat$e2_treat, levels=c("Integration Problems (Turkish)", "Vote Intention (Turkish)",
                                              "Control (Turkish)", "Vote Intention (Canadian)"))

# regression
mod <- lm(e2_response ~ e2_treat*e2_leftpol, 
          data=dat[dat$e2_treat=="Integration Problems (Turkish)" | dat$e2_treat=="Vote Intention (Turkish)",])

# robust standard errors
robust_mod <- coeftest(mod, vcov = vcovHC(mod, "HC1"))

# print results
robust_mod

### NOTE: We do not provide the data and the code to replicate column 2 of table 5 due to concerns of identifiability of politicians. ###


